#pragma once

#include<SFML/Graphics.hpp>
#include<list>

#include"LevelElement.h"
#include"Actor.h"

#define Level_MaxLevelGridSize	80

class Level
{
private:
	LevelElement *_GridLevelElement[Level_MaxLevelGridSize][Level_MaxLevelGridSize];
	sf::Vector2i _GridLevelSize;
	int _GridLevelElementToRefresh[Level_MaxLevelGridSize][Level_MaxLevelGridSize];
	std::list<Actor*> _ListActor;
	int _IsClosed;

public:
	//Initialization
	Level(void);
	~Level(void);

	//Methods
	void Think();
	void Draw(sf::RenderWindow &pRenderWindow);
	void DrawAll(sf::RenderWindow &pRenderWindow);

	int IsOnLevelGridX(Actor& pActor);
	int IsOnLevelGridY(Actor& pActor);
	int IsOnLevelGrid(Actor& pActor);
	void RefreshRequest(Actor& pActor);
	int IsRefreshRequested(int pGridX, int pGridY) { return _GridLevelElementToRefresh[pGridY][pGridX]; }
	void SetAsRefreshed(int pGridX, int pGridY) { _GridLevelElementToRefresh[pGridY][pGridX] = false; }
	LevelElement* SearchLevelElement(int pX, int pY);
	LevelElement* SearchLevelElementFromActor(Actor& pActor, ActorOrientation pOrientation = None);
	int CanTakeOrientation(ActorOrientation pOrientation, Actor& pActor);
	int CanContinueThisWay(ActorOrientation pOrientation, Actor& pActor);

	//Properties
	LevelElement* GetLevelElementInGrid(int pX, int pY) { return _GridLevelElement[pY][pX]; }
	void PushLevelElementInGrid(LevelElement *pLevelElement);
	std::list<Actor*>& GetListActor() { return _ListActor; }
	int IsClosed() { return _IsClosed; }
};
